package com.yaodian100.mall.shopping.web;

import java.util.List;

import org.apache.commons.lang.xwork.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import com.yaodian100.core.common.dao.impl.CommonCriteria;
import com.yaodian100.ec.cobranding.entity.DPNStore;
import com.yaodian100.ec.cobranding.service.DPNService;

public class DaphneAction extends ActionSupport implements Preparable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final Logger logger = LoggerFactory.getLogger(DaphneAction.class);
	@Autowired
	private DPNService dpnService;
	private String storeArea;
	private String actionResult;

	@Override
	public void prepare() throws Exception {
		clearErrorsAndMessages();
	}

	/**
	 * 查询达芙妮门市
	 * 
	 * @return
	 * @throws Exception
	 */
	public String findDaphnes() throws Exception {
		if (StringUtils.isNotBlank(storeArea)) {
			CommonCriteria crit = new CommonCriteria();
			crit.addEq("storeArea", storeArea);
			List<DPNStore> DPNStores = dpnService.getDPNStoretList(crit);
			actionResult = StringUtils.defaultString(actionResult);
			for (DPNStore dpnstore : DPNStores) {
				actionResult = actionResult + dpnstore.getStoreId() + "," + dpnstore.getStoreAddress() + "("
						+ dpnstore.getStoreName() + "-" + dpnstore.getStoreType() + ")" + "$";
			}
			if (actionResult.length() > 0) {
				actionResult = actionResult.substring(0, actionResult.length() - 1);
			}
		}
		return "jsonGetDaphnes";
	}

	public String getStoreArea() {
		return storeArea;
	}

	public void setStoreArea(String storeArea) {
		this.storeArea = storeArea;
	}

	public String getActionResult() {
		return actionResult;
	}

	public void setActionResult(String actionResult) {
		this.actionResult = actionResult;
	}

	public void setDpnService(DPNService dpnService) {
		this.dpnService = dpnService;
	}

}
